define(["jquery", "easy-admin"], function ($, ea) {

    var init = {
        table_elem: '#currentTable',
        table_render_id: 'currentTableRenderId',
        index_url: 'user/index',
        edit_url: 'user/edit',
        modify_url: 'user/modify',
        password_url: 'user/password',
        export_url: 'user/export',
    };

    var Controller = {

        index: function () {
            ea.table.render({
                init: init,skin:'all',
                toolbar: ['refresh','export'],
                cols: [[
                    {field: 'id',width: 120, title: 'ID',search: true},
                    {field: 'username', width: 140, title: '登录账户',search: true},
                    {field: 'nick_name', minWidth: 80, title: '昵称',search: true},
                    {field: 'status', title: '状态', width: 85, search: 'select', selectList: userStatusSelect, templet: ea.table.switch},
                    {field: 'last_login_time', width: 200, title: '最近登录时间', search: 'range'},
                    {field: 'last_login_ip', width: 200, title: '最近登录IP', search: true},
                    {field: 'create_time', width: 200, title: '创建时间', search: 'range'},
                    {
                        width: 180,
                        title: '操作',
                        templet: ea.table.tool,
                        operat: [
                            'edit',
                            [{
                                text: '设置密码',
                                url: init.password_url,
                                method: 'open',
                                auth: 'password',
                                class: 'layui-btn layui-btn-normal layui-btn-xs',
                            }],
                        ]
                        /*templet:function (e){
                            var editBtn='';
                            if(userType==3){
                                editBtn='<a class="layui-btn layui-btn-xs layui-btn-warn" data-full="false" data-open="'+init.edit_url+'?id='+e.id+'" data-title="修改">修改</a>';
                            }
                            return editBtn;
                        }*/
                    }
                ]],
            });
            ea.listen();
        },
        edit: function () {
            ea.listen();
        },
        password: function () {
            ea.listen();
        }
    };
    return Controller;
});